﻿using System.Collections;
using System.Collections.Generic;
using GameFramework;
using GameFramework.Procedure;
using UnityEngine;
using UnityGameFramework.Runtime;
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;

public class ProcedureLogin:ProcedureBase
{
	private bool isCrateRole = false;

    protected override void OnEnter(ProcedureOwner procedureOwner)
    {
        base.OnEnter(procedureOwner);
		isCrateRole = false;
        //加载UI组件
        UIComponent UI = UnityGameFramework.Runtime.GameEntry.GetComponent<UIComponent>();
        //加载UI

        UIFormConfig uiFormCfg = UIFormConfig.GetRowById((int)UIForms.LoginForm);
		UI.OpenUIForm(AppConsts.UIResPath + uiFormCfg.AssetName, uiFormCfg.UIGroupName,this);
    }

	//进入创建角色界面
	public void CrateRole()
	{
		isCrateRole = true;
	}

	protected override void OnUpdate (ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
	{
		base.OnUpdate (procedureOwner, elapseSeconds, realElapseSeconds);
		if (isCrateRole) {
			ChangeState<ProcedureCrate> (procedureOwner);
		}
	}

	protected override void OnLeave (ProcedureOwner procedureOwner, bool isShutdown)
	{
		base.OnLeave (procedureOwner, isShutdown);
		//加载UI组件
		UIComponent UI = UnityGameFramework.Runtime.GameEntry.GetComponent<UIComponent>();
		//关闭UI

		UIFormConfig uiFormCfg = UIFormConfig.GetRowById((int)UIForms.LoginForm);
		UI.CloseUIForm(UI.GetUIForm (AppConsts.UIResPath + uiFormCfg.AssetName));
	}
}